import { createSSRApp } from "vue";
import App from "./App.vue";
import { createPinia } from 'pinia';
import uviewPlus from 'uview-plus';

export function createApp() {
  const app = createSSRApp(App);
  app.use(createPinia());
  app.use(uviewPlus);
  
  // 开发环境下启用HTTP性能测试
  if (process.env.NODE_ENV === 'development') {
    // 延迟加载性能测试模块，避免影响启动速度
    setTimeout(() => {
      import('../utils/http/testRunner').then(({ addPerformanceTestButtons }) => {
        addPerformanceTestButtons()
        console.log('🧪 HTTP性能测试已启用，查看页面右上角测试按钮')
      }).catch((error) => {
        console.log('📝 HTTP性能测试模块加载失败:', error)
        console.log('💡 你可以手动在控制台运行测试')
      })
    }, 2000) // 2秒后加载，确保页面已完全初始化
  }
  
  return {
    app,
  };
}